import openai
import test2



if __name__ == "__main__":
    query = input("请输入要查询的内容：\r\n")
    openai.api_base = "http://localhost:8000/v1"
    openai.api_key = "none"
    res = openai.ChatCompletion.create(
        model="chatglm3-6b",
        messages=[
            {"role": "user", "content": query+",针对这个问题帮我优化一下在搜索引擎中该如何搜索，只输出一行关键词，不要其他内容"}
        ],
    )
    querycontent = res.choices[0].message.content
    
    reslist = test2.getfrombing(querycontent)
    reslist = str(reslist)
    res2 = openai.ChatCompletion.create(
        model="chatglm3-6b",
        messages=[
            {"role": "user", "content": query+",这个问题在搜索引擎中的结果如下：\r\n"+reslist+"\r\n请结合你自己的理解回答一下刚才的的问题"}
        ],
    )
    rescontent = res2.choices[0].message.content
    print(rescontent)

